package com.token.sysflow.bean;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;
import com.token.sql.IntegrateSql;
import com.token.sql.AbstractTableBean;
/**
 * 环节控制字段
 * @author 代码创建
 */
public class FlowStepControl extends AbstractTableBean {

	private String StepId; //环节ID
	private String FlowId; //流程ID
	private String DefaultOpinion; //默认意见
	private String EditFields; //可编辑字段
	private String NeedFields; //必填字段
	private String FocusFields; //关注字段
	private String ModifyFields; //记录字段

	public static String TABLE_NAME = "Flow_StepControl";
	public static String TABLEKEY_NAME = "StepId";
	public FlowStepControl (IntegrateSql f){
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
	}

	public FlowStepControl (IntegrateSql f,ResultSet rs) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		this.initParamToRs(rs);
	}

	public FlowStepControl (IntegrateSql f,String keyValue) throws SQLException{
		super(f,TABLE_NAME);
		this.setKeyName(TABLEKEY_NAME);
		setCodePrepare(selectCodeById().toString());
		prepareSql.setPstValue(1, keyValue);
		ResultSet rs = executeQuery();
		if(rs.next()){
			initParamToRs(rs);
		}else{
			initParam();
		}
		rs.close();
	}

	@Override
	protected void initParam() {
		StepId = ""; //环节ID
		FlowId = ""; //流程ID
		DefaultOpinion = ""; //默认意见
		EditFields = ""; //可编辑字段
		NeedFields = ""; //必填字段
		FocusFields = ""; //关注字段
		ModifyFields = ""; //记录字段
	}


	public void initParamToRs(ResultSet rs) throws SQLException{
		StepId = rs.getString("StepId"); //环节ID
		FlowId = rs.getString("FlowId"); //流程ID
		DefaultOpinion = rs.getString("DefaultOpinion"); //默认意见
		EditFields = rs.getString("EditFields"); //可编辑字段
		NeedFields = rs.getString("NeedFields"); //必填字段
		FocusFields = rs.getString("FocusFields"); //关注字段
		ModifyFields = rs.getString("ModifyFields"); //记录字段
		this.setKeyId(rs.getString("StepId"));
	}


	@Override
	protected int appendData() throws SQLException {
		int i = 1;
		prepareSql.setPstValue(i++,StepId); //环节ID
		prepareSql.setPstValue(i++,FlowId); //流程ID
		prepareSql.setPstValue(i++,DefaultOpinion); //默认意见
		prepareSql.setPstValue(i++,EditFields); //可编辑字段
		prepareSql.setPstValue(i++,NeedFields); //必填字段
		prepareSql.setPstValue(i++,FocusFields); //关注字段
		prepareSql.setPstValue(i++,ModifyFields); //记录字段
		return i;
	}


	@Override
	public Vector<String> getFields() {
		Vector<String> vec = new Vector<String>();
		vec.addElement("StepId"); //环节ID
		vec.addElement("FlowId"); //流程ID
		vec.addElement("DefaultOpinion"); //默认意见
		vec.addElement("EditFields"); //可编辑字段
		vec.addElement("NeedFields"); //必填字段
		vec.addElement("FocusFields"); //关注字段
		vec.addElement("ModifyFields"); //记录字段
		return vec;
	}


	/**
	 * 设置环节ID
	 * @param stepid
	 */
	public void setStepId(String stepid){
		StepId = stepid;
	}
	/**
	 * 获取StepId
	 * @return 环节ID
	 */
	public String getStepId(){
		return StepId;
	}

	/**
	 * 设置流程ID
	 * @param flowid
	 */
	public void setFlowId(String flowid){
		FlowId = flowid;
	}
	/**
	 * 获取FlowId
	 * @return 流程ID
	 */
	public String getFlowId(){
		return FlowId;
	}

	/**
	 * 设置默认意见
	 * @param defaultopinion
	 */
	public void setDefaultOpinion(String defaultopinion){
		DefaultOpinion = defaultopinion;
	}
	/**
	 * 获取DefaultOpinion
	 * @return 默认意见
	 */
	public String getDefaultOpinion(){
		return DefaultOpinion;
	}

	/**
	 * 设置可编辑字段
	 * @param editfields
	 */
	public void setEditFields(String editfields){
		EditFields = editfields;
	}
	/**
	 * 获取EditFields
	 * @return 可编辑字段
	 */
	public String getEditFields(){
		return EditFields;
	}

	/**
	 * 设置必填字段
	 * @param needfields
	 */
	public void setNeedFields(String needfields){
		NeedFields = needfields;
	}
	/**
	 * 获取NeedFields
	 * @return 必填字段
	 */
	public String getNeedFields(){
		return NeedFields;
	}

	/**
	 * 设置关注字段
	 * @param focusfields
	 */
	public void setFocusFields(String focusfields){
		FocusFields = focusfields;
	}
	/**
	 * 获取FocusFields
	 * @return 关注字段
	 */
	public String getFocusFields(){
		return FocusFields;
	}

	/**
	 * 设置记录字段
	 * @param modifyfields
	 */
	public void setModifyFields(String modifyfields){
		ModifyFields = modifyfields;
	}
	/**
	 * 获取ModifyFields
	 * @return 记录字段
	 */
	public String getModifyFields(){
		return ModifyFields;
	}

}
